﻿@using ORM.Framework.Security;
@using ORM.Common.Helpers;
@using ORM.Helpers
<div id="loginarea">
    @if (!User.Identity.IsAuthenticated)
    {
        <div id="toplinks" class="toplinks">
            <ul class="nouser">
                <li><a href="/Account/Register">Đăng Ký</a> </li>
                <li><a href="/Account/Login" id="loginLink"> Đăng Nhập</a></li>
               @* <li id="LogonBt"><a href= 'javascript:showLogonDialog();'>Đăng Nhập</a> </li>
                <script type="text/javascript">
                    function showLogonDialog() {
                        $('#LogonBt').load("/Account/Login?returnUrl="+parent.document.URL.toString());
                        //code vao` day
                    }
                </script>*@
               
            </ul>
         </div>
    }
    else
    {   
        <div id="toplinks" class="toplinks">
            <ul class="nouser">
                <li>
                    <a href="/Account/LogOff" id="logoffLink"> Đăng Xuất</a>
                </li>
                <li>
                    @Html.ActionLink("Đổi Mật Khẩu", "ChangePassword", "Account")
                </li>
                <li>
                    @Html.ActionLink("Trang Của " + SecurityHelper.CurrentUser.UserInfo.Username, "Profile", "Account")
                </li>
                @if (User.IsInRole("Admin"))
                {
                    <li><a href="/Admin/AdminHome">Trang Admin</a> </li>
                }
                @if (User.IsInRole("Approver"))
                {
                <li><a href="/Admin/ManageApproval/QuestionApprovalIndex">Duyệt Bài</a> </li>
                }
            </ul>
        </div> 

                
               
    }
</div>
<script type="text/javascript">
    $(function () {
        $('#loginLink').click(function () {
            var currentUrl = window.location;
            $(this).attr('href', this.href + '?returnUrl=' + currentUrl);
            return true;
        });
        $('#logoffLink').click(function () {
            var currentUrl = window.location;
            $(this).attr('href', this.href + '?returnUrl=' + currentUrl);
            return true;
        });
    });
</script>